//
//  SwitchSettingCell.m
//  18Birdies
//
//  Created by Lc on 15/4/28.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import "LcFoundation.h"
#import "SwitchSettingCell.h"
#import "SwitchSettingCellData.h"

@implementation SwitchSettingCell

- (void)postContruct {
  [super postContruct];
  [self.titleLabel setLcFont:[LcFont dr17]];
  [self.title2Label setLcFont:[LcFont dr17]];
  [self.subtitleLabel setLcFont:[LcFont gr12]];
  self.switchButton.onTintColor = LC_COLOR_BLUE;
  [self.switchButton addTarget:self
                        action:@selector(switchButtonClicked)
              forControlEvents:UIControlEventValueChanged];
}

- (void)switchButtonClicked {
  LC_CHECK_NOT_NULL(self.cellData);
  SwitchSettingCellData* cellData = (SwitchSettingCellData*)self.cellData;
  cellData.switchOn = self.switchButton.on;
  if (cellData.delegate != nil) {
    [cellData.delegate onSwitchValueChanged:cellData
                                   switchOn:cellData.switchOn];
  }
}

@end
